import axios from 'axios'
import qs from 'qs'

axios.defaults.baseURL = 'http://139.224.128.85:8087/plm-api'

axios.defaults.method = "POST"

axios.defaults.timeout = 10000

axios.interceptors.request.use(config => {
  // 设置请求头
  config.headers = {
    'Content-Type': config.headers['Content-Type'] || 'application/x-www-form-urlencoded',
  }
  if (config.headers['Content-Type'] === 'application/x-www-form-urlencoded') {
    config.data = config.data ? qs.stringify(config.data) : ''
  }
  return config
}, error => {
  return Promise.reject(error)
})

axios.interceptors.response.use( response => {
  return response
}, error => {
  return Promise.reject(error)
})

export default axios